[qemu] Fix PCI config header space writes and set Subsystem-Vendor ID fields.
authorChristian Limpach <Christian.Limpach@xensource.com>
Mon, 28 Aug 2006 21:43:09 +0000 (22:43 +0100)
committerChristian Limpach <Christian.Limpach@xensource.com>
Mon, 28 Aug 2006 21:43:09 +0000 (22:43 +0100)
Fix failure in Windows HCT's PCI-Compliance-Test by invalidating the
writing to read-only/reserved fields in PCI configuration space header
and giving Subsystem-Vendor-ID field a valid value via copying Vendor-ID
field into it.

Signed-off-by: Dexuan Cui <dexuan.cui@intel.com>
tools/ioemu/hw/pci.c
tools/ioemu/hw/rtl8139.c
tools/ioemu/hw/usb-uhci.c

index f58f6fd60cd13b1a2d99927e050dc5a2b8409092..77737c8615262a872060d33923e7ef2dbd3f3889 100644 (file)
@@ -286,6 +286,7 @@ void pci_default_write_config(PCIDevice *d,
             case 0x0b:
             case 0x0e:
             case 0x10 ... 0x27: /* base */
+            case 0x2c ... 0x2f: /* subsystem vendor id, subsystem id */
             case 0x30 ... 0x33: /* rom */
             case 0x3d:
                 can_write = 0;
@@ -318,6 +319,18 @@ void pci_default_write_config(PCIDevice *d,
             break;
         }
         if (can_write) {
+            if( addr == 0x05 ) {
+                /* In Command Register, bits 15:11 are reserved */
+                val &= 0x07; 
+            } else if ( addr == 0x06 ) {
+                /* In Status Register, bits 6, 2:0 are reserved, */
+                /* and bits 7,5,4,3 are read only */
+                val = d->config[addr];
+            } else if ( addr == 0x07 ) {
+                /* In Status Register, bits 10,9 are reserved, */
+                val = (val & ~0x06) | (d->config[addr] & 0x06);
+            }
+
             d->config[addr] = val;
         }
         addr++;
index 9c613a8f93134638ddc5c19e93ad5d7eb84375ee..c704ab83607b6bb33b53e33e82a425be7b9b2b78 100644 (file)
@@ -3423,6 +3423,8 @@ void pci_rtl8139_init(PCIBus *bus, NICInfo *nd)
     pci_conf[0x0e] = 0x00; /* header_type */
     pci_conf[0x3d] = 1;    /* interrupt pin 0 */
     pci_conf[0x34] = 0xdc;
+    pci_conf[0x2c] = pci_conf[0x00]; // same as Vendor ID
+    pci_conf[0x2d] = pci_conf[0x01];
 
     s = &d->rtl8139;
 
index 1a6e0130f9753979f6c41c42937d42b7caa289f3..c6394cdda312af3a437d98cc50525563320e8360 100644 (file)
@@ -659,6 +659,8 @@ void usb_uhci_init(PCIBus *bus, int devfn)
     pci_conf[0x0e] = 0x00; // header_type
     pci_conf[0x3d] = 4; // interrupt pin 3
     pci_conf[0x60] = 0x10; // release number
+    pci_conf[0x2c] = pci_conf[0x00]; // same as Vendor ID
+    pci_conf[0x2d] = pci_conf[0x01];
     
     for(i = 0; i < NB_PORTS; i++) {
         qemu_register_usb_port(&s->ports[i].port, s, i, uhci_attach);